﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BlogDemo.Application;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BlogDemo.Api.Controllers
{
    //create POST
    //add POST
    //post POST
    //get GET
    //find GET
    //fetch GET
    //query GET
    //update PUT
    //put PUT
    //delete DELETE
    //remove DELETE

    //[ApiVersion("1.0")]
    //[Route("api/v{version:apiVersion}/[controller]")]
    [Route("api/values")]
    [ApiController]
    [Authorize]
    public class ValuesController : ControllerBase
    {
        /// <summary>
        ///  获取资源数据列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        //GET api/values
        public ActionResult<IEnumerable<string>> Get()
        {
            return Ok( new string[] { "value1", "value2" });
        }
        /// <summary>
        /// 获取单个资源
        /// </summary>
        /// <remarks>
        /// 例子:
        /// GET api/values/5
        /// </remarks>
        /// <param name="id">主键</param>
        /// <returns>测试字符串</returns>      
        [ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
        [ProducesResponseType(StatusCodes.Status404NotFound)]
        [HttpGet]
        [Route("{id}")]
        public ActionResult<string> Get(int id)
        {
            return $"你请求的 id 是 {id}";
        }
        /// <summary>
        /// 新增一个资源
        /// </summary>
        /// <param name="value"></param>
        // POST api/values
        [ProducesResponseType(typeof(string), StatusCodes.Status201Created)]
        [ProducesResponseType(StatusCodes.Status400BadRequest)]
        [HttpPost]
        [Route("{id}")]
        public void Post([FromBody] string value)
        {
        }

        /// <summary>
        /// 修改一个资源
        /// </summary>
        /// <param name="id"></param>
        /// <param name="value"></param>
        // PUT api/values/5
        [ProducesResponseType(typeof(string), StatusCodes.Status201Created)]
        [ProducesResponseType(StatusCodes.Status400BadRequest)]
        [HttpPost]
        [Route("{id}")]
        public void Put(int id, [FromBody] string value)
        {
        }

        /// <summary>
        /// 修改一个资源中某些内容
        /// </summary>
        /// <param name="id"></param>
        /// <param name="value"></param>
        [ProducesResponseType(StatusCodes.Status200OK)]
        [ProducesResponseType(StatusCodes.Status400BadRequest)]
        [ProducesResponseType(StatusCodes.Status404NotFound)]
        [HttpPut]
        [Route("{id}")]
        public void Patch(int id, [FromBody] string value)
        {

        }

        /// <summary>
        /// 删除一个资源
        /// </summary>
        /// <param name="id"></param>
        // DELETE api/values/5
        [ProducesResponseType(StatusCodes.Status200OK)]
        [ProducesResponseType(StatusCodes.Status404NotFound)]
        [HttpDelete]
        [Route("{id}")]
        public void Delete(int id)
        {
        }
    }
}
